import tkinter as tk
from tkinter import messagebox
import random

# 预设的犯人特征
features = {
    "发型": ["长发", "短发", "卷发", "光头"],
    "脸型": ["圆脸", "瓜子脸", "方脸", "鹅蛋脸"],
    "眼睛": ["大眼睛", "小眼睛", "丹凤眼", "双眼皮"],
    "鼻子": ["高鼻梁", "塌鼻梁", "鹰钩鼻"],
    "嘴巴": ["大嘴", "小嘴", "厚嘴唇", "薄嘴唇"]
}

# 随机生成犯人的特征
criminal_features = {
    feature: random.choice(options) for feature, options in features.items()
}

# 绘画板类
class DrawingBoard:
    def __init__(self, root):
        self.root = root
        self.canvas = tk.Canvas(root, width=400, height=400, bg="white")
        self.canvas.pack()
        self.prev_x = None
        self.prev_y = None
        self.canvas.bind("<B1-Motion>", self.paint)
        self.canvas.bind("<ButtonRelease-1>", self.reset)

    def paint(self, event):
        x, y = event.x, event.y
        if self.prev_x and self.prev_y:
            self.canvas.create_line((self.prev_x, self.prev_y, x, y), width=2, fill="black")
        self.prev_x = x
        self.prev_y = y

    def reset(self, event):
        self.prev_x = None
        self.prev_y = None

# 特征显示和提交类
class FeatureDisplayAndSubmit:
    def __init__(self, root):
        self.root = root
        self.feature_label = tk.Label(root, text="犯人特征如下：\n" +
                                               "\n".join([f"{feature}: {value}" for feature, value in
                                                          criminal_features.items()]))
        self.feature_label.pack()
        self.submit_button = tk.Button(root, text="提交画像", command=self.evaluate)
        self.submit_button.pack()

    def evaluate(self):
        # 这里简单模拟评价，实际可以有更复杂的逻辑
        accuracy = random.randint(20, 80)
        messagebox.showinfo("评价结果", f"你画的画像与描述的相似度约为 {accuracy}%。")

# 主程序
if __name__ == "__main__":
    root = tk.Tk()
    root.title("犯人画像游戏")

    drawing_board = DrawingBoard(root)
    feature_display = FeatureDisplayAndSubmit(root)

    root.mainloop()